package com.atguigu.guli.service.edu.controller.admin;


import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.Chapter;
import com.atguigu.guli.service.edu.entity.Video;
import com.atguigu.guli.service.edu.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author leo
 * @since 2021-11-24
 */
@RestController
@RequestMapping("/admin/edu/video")

public class AdminVideoController {
    @Autowired
    VideoService videoService ;
    @PostMapping("save")
    public R save(@RequestBody Video video) {
        videoService.save(video) ;
        return R.ok() ;
    }

    @DeleteMapping("delete/{videoId}")
    public R delete(@PathVariable String videoId) {
        videoService.removeById(videoId) ;
        return R.ok() ;
    }

    @GetMapping("getById/{videoId}")
    public R update(@PathVariable String videoId) {
        Video video = videoService.getById(videoId) ;
        return R.ok().data("item",video) ;
    }

    @PutMapping("update")
    public R update(@RequestBody Video video) {
        videoService.updateById(video) ;
        return R.ok() ;
    }

}

